package com.example.sistemacompras;

import com.example.sistemacompras.db.DatabaseHandler;
import com.example.sistemacompras.entity.Client;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class UserProfileActivity extends Activity {
	private DatabaseHandler db;

	private Client mClient;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_user_profile);
		db = new DatabaseHandler(this);

		int id = getIntent().getExtras().getInt("user_id");
		mClient = db.getClientById(id);
	}

	public void goToBoughtView(View view) {

		Intent intent = new Intent(this, OrdersHistory.class);
		intent.putExtra("user_id", mClient.getId());
		startActivity(intent);
	}

	public void goToUserOperationsView(View view) {
		Intent intent = new Intent(this, UserOperationsActivity.class);
		intent.putExtra("user_id", mClient.getId());
		startActivity(intent);
		finish();
	}
    
    public void goToListProductView(View view) {
    	Intent intent = new Intent(this, ProductListActivity.class);
        intent.putExtra("user_id", mClient.getId());
        startActivity(intent);
	}

	public void goToNewproductView(View view) {
		Intent intent = new Intent(this, ProductsSignActivity.class);
		intent.putExtra("user_id", mClient.getId());
		startActivity(intent);
	}

	@Override
	public void onBackPressed() {
		Intent intent = new Intent(this, UserHomeActivity.class);
		intent.putExtra("user_id", mClient.getId());
		startActivity(intent);

		super.onBackPressed();
	}
}
